package packge.util;

import java.util.*;

class UtilTest1 {
	public static void main(String str[]) {
		List col = new ArrayList();
		col.add("sri");
		col.add("JSP");
		col.add("JAVA");
		System.out.println(col);
		ListIterator lit = col.listIterator();
		System.out.println(lit);
		System.out.println("--- Forward Direction ---");
		while (lit.hasNext()) {
			Object object = (Object) lit.next();
			System.out.println(lit.nextIndex() + "\t" + object);
		}
		System.out.println("-- Reverse Direction --");
		while (lit.hasPrevious()) {
			Object object = (Object) lit.previous();
			System.out.println(object);
		}
		System.out.println("-- Reverse Direction --");
		lit = col.listIterator(5);
		while (lit.hasPrevious()) {
			Object object = (Object) lit.previous();
			System.out.println(object);
		}
		System.out.println("-- Reverse Direction --");
		lit = col.listIterator(5);
		while (lit.hasNext()) {
			Object object = (Object) lit.next();
			System.out.println(object);
		}
		lit = col.listIterator();
		while (lit.hasNext()) {
			Object object = (Object) lit.next();
			if (object.equals("RMI"))
				lit.add("Hello");
			if (object.equals("JSP"))
				lit.add("Servlet/Jsp");
			if (object.equals("Manish"))
				lit.remove();
		}
		System.out.println(col);
	}
}